package qldc.pm.tiensu.util;

import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;

/**
 * Custom String utilities
 * @author TriLe
 *
 */
public class StringUtils {
	/**
	 * add % at the start and end of a String.
	 * @param value the String that will be added % at the start and end
	 * @return the String after adding % at the start and end of the given String
	 */
	public static String getLike(String value) {
		if(Validator.isNull(value)) {
			return StringPool.PERCENT + StringPool.PERCENT;
		} else {
			if(!value.startsWith(StringPool.PERCENT)) {
				value = StringPool.PERCENT + value;
			}

			if(!value.endsWith(StringPool.PERCENT)) {
				value += StringPool.PERCENT;
			}

			return value;
		}
	}
}
